package com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.common.persistence.model.User;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.base.SqlMapper;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.dao.CacheImageDao;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.dao.DentalImageDao;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.QualityAssuranceInfo;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.RootImageInfo;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.SearchQualityAssuranceInfo;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.entity.SearchRootImageInfo;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.service.ICacheImageService;
import com.sxfq.loansupermarket.backsystem.modular.qualityAssurance.service.IDentalImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 质量管理Dao
 *
 * @author fengshuonan
 * @Date 2019-09-01 15:34:05
 */
@Service
public class CacheImageServiceImpl implements ICacheImageService {
    @Autowired
    private CacheImageDao dao;

    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<RootImageInfo> selectOrthodonticsByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesOrthodonticsCache(page, params);
    }

    @Override
    public int getOrthodonticsCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesOrthodonticsCacheCount(page, params);
    }

    @Override
    public List<RootImageInfo> selectCanalByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesCanalCache(page, params);
    }

    @Override
    public int getCanalCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesCanalCacheCount(page, params);
    }

    @Override
    public List<RootImageInfo> selectScalingByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesScalingCache(page, params);
    }

    @Override
    public int getScalingCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesScalingCacheCount(page, params);
    }

    @Override
    public List<RootImageInfo> selectPeriodontalByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesPeriodontalCache(page, params);
    }

    @Override
    public int getPeriodontalCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesPeriodontalCacheCount(page, params);
    }

    @Override
    public List<RootImageInfo> selectPlantByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesPlantCache(page, params);
    }

    @Override
    public int getPlantCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesPlantCacheCount(page, params);
    }

    @Override
    public List<RootImageInfo> selectRepairByCache(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getQueryPagesRepairCache(page, params);
    }

    @Override
    public int getRepairCacheCount(Page<RootImageInfo> page, SearchRootImageInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getStartCreateTime())) {
            params.put("startCreateTime", searchInfo.getStartCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndCreateTime())) {
            params.put("endCreateTime", searchInfo.getEndCreateTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCreateName())) {
            params.put("createName", searchInfo.getCreateName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArrivalStore())) {
            params.put("arrivalStore", searchInfo.getArrivalStore());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStatus())) {
            params.put("status", searchInfo.getStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getArea())) {
            params.put("area", searchInfo.getArea());
        }
        if (StringUtil.isNotEmpty(searchInfo.getType())) {
            params.put("type", searchInfo.getType());
        }
        if (StringUtil.isNotEmpty(searchInfo.getDoctor())) {
            params.put("doctor", searchInfo.getDoctor());
        }else {
            String sql = "select b.id as roleid from user a left join role b on a.roleId=b.id where a.account='" + ShiroKit.getUser().getAccount() + "'";
            User user = sqlMapper.selectOne(sql, User.class);
            if (user != null) {
                if ("1".equals(user.getRoleid()) || "1,".equals(user.getRoleid().substring(0, 2))) {
                    params.put("doctor", "");
                } else {
                    params.put("doctor", ShiroKit.getUser().getAccount());
                }
            }
        }
        return dao.getQueryPagesRepairCacheCount(page, params);
    }
}
